/**
 * @param {number} n
 * @param {number} k
 * @return {string}
 * 1234
 * 1243
 */
var getPermutation = function (n, k) {
  let i = 1
  let defaultNum = []
  while (i <= n) {
    defaultNum.push(i)
    i++
  }
  let left = defaultNum.length - 2
  let right = defaultNum.length - 1
  while (defaultNum[left] >= defaultNum[right] && left >= 0 && right > 0) {
    if (left === 0) {
      right--
      left = right
    }
    left--
  }
  const tem = defaultNum[left]
  defaultNum[left] = defaultNum[right]
  defaultNum[right] = tem
}
